package cn.vendai.com.controller;

import cn.vendai.com.service.ConversationService;
import cn.vendcommon.com.entity.Result;
import cn.vendcommon.com.utils.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/conversation")
public class ConversationController {

    @Autowired
    private ConversationService conversationService;

    /**
     * 新建对话
     */
    @GetMapping("/create")
    public Result<String> createConversation() {
        int userId = Math.toIntExact(UserContext.getUserId());
        String conversationId = conversationService.createConversation(userId);
        return Result.success(conversationId);
    }
}
